<template>
  <van-row>
    <van-row>
      <van-col :span="24">
        <van-grid clickable :column-num="2" :border="false">
          <van-grid-item icon="./static/imgs/mycreate.png" text="我的任务" to="/mytaskdetail/1" v-if="myCreateCount>0"
            :badge="myCreateCount" />
          <van-grid-item icon="./static/imgs/mycreate.png" text="我的任务" to="/mytaskdetail/1" v-else />
          <van-grid-item icon="./static/imgs/mytask.png" text="指派给我" to="/mytaskdetail/2" v-if="apponitMyTask>0"
            :badge="apponitMyTask" />
          <van-grid-item icon="./static/imgs/mytask.png" text="指派给我" to="/mytaskdetail/2" v-else />
        </van-grid>
      </van-col>
    </van-row>
  </van-row>
</template>

<script>
  import {
    Row,
    Col,
    Grid,
    GridItem,
  } from 'vant';
  export default {
    name: "myTask",
    data: function () {
      return {
        myCreateCount: '',
        apponitMyTask: '',
      }
    },
    components: {
      'van-row': Row,
      'van-col': Col,
      'van-grid-item': GridItem,
      'van-grid': Grid,

    },
    methods: {
      //获取我的任务信息
      async getMytask() {
        var res = await this.$ajax.get(`/api/task/my/${ this.$user.getUserName()}`);
        if (res.status == 1) {
          Toast.fail(res.msg);
          return;
        }
        this.myCreateCount = res.data.myCreateCount;
        this.apponitMyTask = res.data.appointMyTask;
      }
    },
    async mounted() {
      await this.getMytask();
    }
  }

</script>
